<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<%@ taglib prefix="tag" tagdir="/WEB-INF/tags/system/" %>
<script type="text/javascript" src="${ctxPath}/resource/common/js/tagSelector.js"></script>

<script type="text/javascript">
var tagIndex = '${fn:length(tags)}';
function addTagSpan(){
	var objSource=$("#tag")[0];
	var sourceLen = objSource.options.length;
	for (var i = 0; i < sourceLen; i++) {
		if (objSource.options[i].selected) {
			var searchKey = objSource.options[i].value;
			if(searchKey==""){
				alert("不能选择标题项！");
				return;
			}
			var selectedTagId = $("input:hidden[name='_${param['tagInputName']}']");
			for (var j = 0; j < selectedTagId.length; j++) {
				if (searchKey == selectedTagId.get(j).value) {
					return;
				}
			}
			var spanTag = "<span id='_${param['tagInputName']}"+tagIndex+"'><input type='hidden' name='_${param['tagInputName']}' value='"+searchKey+"'>";
			spanTag += "<input type='hidden' name='_tagName' value='"+objSource.options[i].text+"'>";
			spanTag += objSource.options[i].text+"&nbsp;<a href='javascript:removeTag(\"${param['tagInputName']}"+tagIndex+"\")'>X</a></span>&nbsp;";
			$("#_selectdTagsDiv").append(spanTag);
			tagIndex++;
		}
	}
}
</script>

<center>
<tag:tagSelector ondbclick="addTagSpan();" size="10" cssClass="width:100px;">
</tag:tagSelector>
<div id="_selectdTagsDiv">
	<c:forEach items="${tags}" var="tag" varStatus="index"  >
		<span id="_${param['tagInputName']}${index.index}">
			<input type="hidden" name="_${param['tagInputName']}" value="${tag.tagId}">
			<input type="hidden" name="_tagName" value="${tag.tagName}">
			${tag.tagName}
			<a href="javascript:removeTag('_${param['tagInputName']}${index.index}')">X</a>
		</span>
	</c:forEach>
</div>
</center>
